In order to perform the dynamic linking, load-foreign first has to figure out
the file containing the relocation information for the current state
of the running T process.
The filename is specified as the value returned by the switch
reloc-file in the t-implementation-env.
It then page aligns the current end of allocated memory.
Next, the file to be loaded in is relocated and linked by calling on
/bin/ld -A
to do the job.
It is at this point that the libraries are linked in.
The actual /bin/ld
command that is executed looks like
/bin/ld
run
and contains the result of the relocation.
This file also contains the new relocation information and after
successful loading, the switch reloc-file is set to be this file
name.
tfile is created in /tmp
and has a name that starts
with the letters dyn.
str is the library string specified in the load-foreign command.
After successful relocation, the temporary file's header is read to figure out how much extra space is required. Next, that much extra space is requested from UNIX and the data from the temporary file is read in.